subroutine calcene(t1, t2, fia, iabij, eccsd)
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
!use common
implicit none
real*8, intent(inout) :: eccsd
real*8, intent(in) :: t1(*), t2(*), fia(*), iabij(*) 
!
if(prec==8.and.igpu==0) then 
   call calcene_d(t1, t2, fia, iabij, eccsd)
elseif(prec==4.and.igpu==0) then 
   call calcene_s(t1, t2, fia, iabij, eccsd)
elseif(prec==8.and.igpu==1) then 
   call calcene_dg(t1, t2, fia, iabij, eccsd)
elseif(prec==4.and.igpu==1) then 
   call calcene_sg(t1, t2, fia, iabij, eccsd)
endif
!
return
end

subroutine calcene_d(t1, t2, fia, iabij, eccsd)
!use common
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
implicit none
real*8, intent(inout) :: eccsd
real*8, intent(in) :: t1(*), t2(*), fia(*), iabij(*)
!
real*8 :: eso
real*8, external :: ddot
!
eso = ddot(nifvo, t1, 1, fia, 1)
eccsd = ddot(nioi3, t2, 1, iabij, 1) + eso
!
return
end
!
subroutine calcene_s(t1, t2, fia, iabij, eccsd)
!use common
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
implicit none
real*8, intent(inout) :: eccsd
real*4, intent(in) :: t1(*), t2(*), fia(*), iabij(*) 
!
real*8 :: eso
real*4, external :: sdot
!
eso = sdot(nifvo, t1, 1, fia, 1)
eccsd = sdot(nioi3, t2, 1, iabij, 1) + eso
!
return
end
!
subroutine calcene_sg(t1, t2, fia, iabij, eccsd)
!use common
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
use cublas
implicit none
real*8, intent(inout) :: eccsd
real*4, intent(in),device :: t1(*), t2(*), fia(*), iabij(*)
!
real*8 :: eso
integer*4 nioi3_4, ioff1, ioff2 
!
ioff1 = 1; ioff2 = 1; nioi3_4=nioi3
eccsd = cublassdot(nioi3_4, t2, ioff1, iabij, ioff2) 
!
return
end
!
subroutine calcene_dg(t1, t2, fia, iabij, eccsd)
!use common
use mod_iop
use mod_size
use mod_orbit
use mod_ioff 
use cublas
implicit none
real*8, intent(inout) :: eccsd
real*8, intent(in), device :: t1(*), t2(*), fia(*), iabij(*)
!
real*8 :: eso
integer*4 nioi3_4, ioff1, ioff2
!
ioff1 = 1; ioff2 = 1; nioi3_4=nioi3
eccsd = cublasddot(nioi3_4, t2, ioff1, iabij, ioff2)
!
return
end

